/**  
* @Title: ProductSaleController.java  
* @Description: TODO(用一句话描述该文件做什么)  
* @author 张鑫
* @phone 17561783855  
* @date 2019年5月22日  
*/
package com.fortune.rainshineservice.controller;

import com.fortune.rainshinecommon.query.GetDetailQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fortune.rainshinecommon.base.MsgModel;
import com.fortune.rainshinecommon.base.ParmsModel;
import com.fortune.rainshinecommon.enums.ResultCode;
import com.fortune.rainshinecommon.model.service.StockRecordsModel;
import com.fortune.rainshineservice.service.ProductSaleService;

/**  
* @ClassName: ProductSaleController  
* @Description: TODO(店铺产品处理--产品销售以及产品领用)  
* @author 张鑫
* @phone 17561783855
* @date 2019年5月22日  
*    
*/
@RestController
@RequestMapping("/productSale")
public class ProductSaleController {
	@Autowired
	private ProductSaleService service;
	

	/**
	 * @Title: saleOrUse
	 * @Description: 产品销售或者领用保存
	 * @author zhangxin
	 * @phone 17561783855
	 * @date 2019年5月22日
	 */
	@PostMapping("/saleOrUse")
    public MsgModel saleOrUse(@RequestBody StockRecordsModel model){
        return service.saleOrUse(model);
    }
	
	/**
	 * @Title: list
	 * @Description: 获取销售或者领用stores_records的列表
	 * @author zhangxin
	 * @phone 17561783855
	 * @date 2019年5月22日
	 */
	@PostMapping("/list")
    public MsgModel list(@RequestBody ParmsModel parm){
        return service.list(parm);
    }

	/**
	 * 领用单详情
	 * @return
	 */
	@PostMapping("/consumeDetails")
	public MsgModel consumeDetails(@RequestBody GetDetailQuery query){
		return service.consumeDetails(query);
	}


	/**
	 * 销售详情
	 * @return
	 */
	@PostMapping("/saleDetails")
	public MsgModel saleDetails(@RequestBody GetDetailQuery query){
		return service.saleDetails(query);
	}
	
	/**
	 * @Title: orderDetail
	 * @Description: 获取销售或者领用订单详情
	 * @author zhangxin
	 * @phone 17561783855
	 * @date 2019年5月22日
	 */
	@PostMapping("/orderDetail")
    public MsgModel orderDetail(@RequestBody ParmsModel parm){
		GetDetailQuery quary = new GetDetailQuery();
		quary.setCode(parm.getCode());
		quary.setPage(parm.getPage());
		quary.setLimit(parm.getLimit());
		if(parm.getType() == 3) {//销售详情
			return service.saleDetails(quary);
		}else if(parm.getType() == 4) {//领用详情
			return service.consumeDetails(quary);
		}
		return new MsgModel("获取详情异常", ResultCode.FAILURE);
    }


}
